

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>lit - LLVM Integrated Tester &#8212; LLVM 9 documentation</title>
    <link rel="stylesheet" href="../_static/llvm-theme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="llvm-build - LLVM Project Build Utility" href="llvm-build.html" />
    <link rel="prev" title="tblgen - Target Description To C++ Code Generator" href="tblgen.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head><body>
<div class="logo">
  <a href="../index.html">
    <img src="../_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="llvm-build.html" title="llvm-build - LLVM Project Build Utility"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="tblgen.html" title="tblgen - Target Description To C++ Code Generator"
             accesskey="P">previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">LLVM Command Guide</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">lit - LLVM Integrated Tester</a></li> 
      </ul>
    </div>


    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <div class="section" id="lit-llvm-integrated-tester">
<h1>lit - LLVM Integrated Tester<a class="headerlink" href="#lit-llvm-integrated-tester" title="Permalink to this headline">¶</a></h1>
<div class="section" id="synopsis">
<h2>SYNOPSIS<a class="headerlink" href="#synopsis" title="Permalink to this headline">¶</a></h2>
<p><strong class="program">lit</strong> [<em>options</em>] [<em>tests</em>]</p>
</div>
<div class="section" id="description">
<h2>DESCRIPTION<a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h2>
<p><strong class="program">lit</strong> is a portable tool for executing LLVM and Clang style test
suites, summarizing their results, and providing indication of failures.
<strong class="program">lit</strong> is designed to be a lightweight testing tool with as simple a
user interface as possible.</p>
<p><strong class="program">lit</strong> should be run with one or more <em>tests</em> to run specified on the
command line.  Tests can be either individual test files or directories to
search for tests (see <a class="reference internal" href="#test-discovery"><span class="std std-ref">TEST DISCOVERY</span></a>).</p>
<p>Each specified test will be executed (potentially in parallel) and once all
tests have been run <strong class="program">lit</strong> will print summary information on the number
of tests which passed or failed (see <a class="reference internal" href="#test-status-results"><span class="std std-ref">TEST STATUS RESULTS</span></a>).  The
<strong class="program">lit</strong> program will execute with a non-zero exit code if any tests
fail.</p>
<p>By default <strong class="program">lit</strong> will use a succinct progress display and will only
print summary information for test failures.  See <a class="reference internal" href="#output-options"><span class="std std-ref">OUTPUT OPTIONS</span></a> for
options controlling the <strong class="program">lit</strong> progress display and output.</p>
<p><strong class="program">lit</strong> also includes a number of options for controlling how tests are
executed (specific features may depend on the particular test format).  See
<a class="reference internal" href="#execution-options"><span class="std std-ref">EXECUTION OPTIONS</span></a> for more information.</p>
<p>Finally, <strong class="program">lit</strong> also supports additional options for only running a
subset of the options specified on the command line, see
<a class="reference internal" href="#selection-options"><span class="std std-ref">SELECTION OPTIONS</span></a> for more information.</p>
<p><strong class="program">lit</strong> parses options from the environment variable <code class="docutils literal notranslate"><span class="pre">LIT_OPTS</span></code> after
parsing options from the command line.  <code class="docutils literal notranslate"><span class="pre">LIT_OPTS</span></code> is primarily useful for
supplementing or overriding the command-line options supplied to <strong class="program">lit</strong>
by <code class="docutils literal notranslate"><span class="pre">check</span></code> targets defined by a project’s build system.</p>
<p>Users interested in the <strong class="program">lit</strong> architecture or designing a
<strong class="program">lit</strong> testing implementation should see <a class="reference internal" href="#lit-infrastructure"><span class="std std-ref">LIT INFRASTRUCTURE</span></a>.</p>
</div>
<div class="section" id="general-options">
<h2>GENERAL OPTIONS<a class="headerlink" href="#general-options" title="Permalink to this headline">¶</a></h2>
<dl class="std option">
<dt id="cmdoption-lit-h">
<span id="cmdoption-lit-help"></span><code class="sig-name descname">-h</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--help</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-h" title="Permalink to this definition">¶</a></dt>
<dd><p>Show the <strong class="program">lit</strong> help message.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-j">
<span id="cmdoption-lit-threads"></span><code class="sig-name descname">-j</code><code class="sig-prename descclassname"> N</code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--threads</code><code class="sig-prename descclassname">=N</code><a class="headerlink" href="#cmdoption-lit-j" title="Permalink to this definition">¶</a></dt>
<dd><p>Run <code class="docutils literal notranslate"><span class="pre">N</span></code> tests in parallel.  By default, this is automatically chosen to
match the number of detected available CPUs.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-config-prefix">
<code class="sig-name descname">--config-prefix</code><code class="sig-prename descclassname">=NAME</code><a class="headerlink" href="#cmdoption-lit-config-prefix" title="Permalink to this definition">¶</a></dt>
<dd><p>Search for <code class="file docutils literal notranslate"><em><span class="pre">NAME</span></em><span class="pre">.cfg</span></code> and <code class="file docutils literal notranslate"><em><span class="pre">NAME</span></em><span class="pre">.site.cfg</span></code> when searching for
test suites, instead of <code class="file docutils literal notranslate"><span class="pre">lit.cfg</span></code> and <code class="file docutils literal notranslate"><span class="pre">lit.site.cfg</span></code>.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-D">
<span id="cmdoption-lit-d"></span><span id="cmdoption-lit-param"></span><code class="sig-name descname">-D</code><code class="sig-prename descclassname"> NAME[=VALUE]</code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--param</code><code class="sig-prename descclassname"> NAME[=VALUE]</code><a class="headerlink" href="#cmdoption-lit-D" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a user defined parameter <code class="docutils literal notranslate"><span class="pre">NAME</span></code> with the given <code class="docutils literal notranslate"><span class="pre">VALUE</span></code> (or the empty
string if not given).  The meaning and use of these parameters is test suite
dependent.</p>
</dd></dl>

</div>
<div class="section" id="output-options">
<span id="id1"></span><h2>OUTPUT OPTIONS<a class="headerlink" href="#output-options" title="Permalink to this headline">¶</a></h2>
<dl class="std option">
<dt id="cmdoption-lit-q">
<span id="cmdoption-lit-quiet"></span><code class="sig-name descname">-q</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--quiet</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-q" title="Permalink to this definition">¶</a></dt>
<dd><p>Suppress any output except for test failures.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-s">
<span id="cmdoption-lit-succinct"></span><code class="sig-name descname">-s</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--succinct</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-s" title="Permalink to this definition">¶</a></dt>
<dd><p>Show less output, for example don’t show information on tests that pass.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-v">
<span id="cmdoption-lit-verbose"></span><code class="sig-name descname">-v</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--verbose</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-v" title="Permalink to this definition">¶</a></dt>
<dd><p>Show more information on test failures, for example the entire test output
instead of just the test result.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-vv">
<span id="cmdoption-lit-echo-all-commands"></span><code class="sig-name descname">-vv</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--echo-all-commands</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-vv" title="Permalink to this definition">¶</a></dt>
<dd><p>Echo all commands to stdout, as they are being executed.
This can be valuable for debugging test failures, as the last echoed command
will be the one which has failed.
<strong class="program">lit</strong> normally inserts a no-op command (<code class="docutils literal notranslate"><span class="pre">:</span></code> in the case of bash)
with argument <code class="docutils literal notranslate"><span class="pre">'RUN:</span> <span class="pre">at</span> <span class="pre">line</span> <span class="pre">N'</span></code> before each command pipeline, and this
option also causes those no-op commands to be echoed to stdout to help you
locate the source line of the failed command.
This option implies <code class="docutils literal notranslate"><span class="pre">--verbose</span></code>.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-a">
<span id="cmdoption-lit-show-all"></span><code class="sig-name descname">-a</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--show-all</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-a" title="Permalink to this definition">¶</a></dt>
<dd><p>Show more information about all tests, for example the entire test
commandline and output.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-no-progress-bar">
<code class="sig-name descname">--no-progress-bar</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-no-progress-bar" title="Permalink to this definition">¶</a></dt>
<dd><p>Do not use curses based progress bar.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-show-unsupported">
<code class="sig-name descname">--show-unsupported</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-show-unsupported" title="Permalink to this definition">¶</a></dt>
<dd><p>Show the names of unsupported tests.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-show-xfail">
<code class="sig-name descname">--show-xfail</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-show-xfail" title="Permalink to this definition">¶</a></dt>
<dd><p>Show the names of tests that were expected to fail.</p>
</dd></dl>

</div>
<div class="section" id="execution-options">
<span id="id2"></span><h2>EXECUTION OPTIONS<a class="headerlink" href="#execution-options" title="Permalink to this headline">¶</a></h2>
<dl class="std option">
<dt id="cmdoption-lit-path">
<code class="sig-name descname">--path</code><code class="sig-prename descclassname">=PATH</code><a class="headerlink" href="#cmdoption-lit-path" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify an additional <code class="docutils literal notranslate"><span class="pre">PATH</span></code> to use when searching for executables in tests.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-vg">
<code class="sig-name descname">--vg</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-vg" title="Permalink to this definition">¶</a></dt>
<dd><p>Run individual tests under valgrind (using the memcheck tool).  The
<code class="docutils literal notranslate"><span class="pre">--error-exitcode</span></code> argument for valgrind is used so that valgrind failures
will cause the program to exit with a non-zero status.</p>
<p>When this option is enabled, <strong class="program">lit</strong> will also automatically provide a
“<code class="docutils literal notranslate"><span class="pre">valgrind</span></code>” feature that can be used to conditionally disable (or expect
failure in) certain tests.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-vg-arg">
<code class="sig-name descname">--vg-arg</code><code class="sig-prename descclassname">=ARG</code><a class="headerlink" href="#cmdoption-lit-vg-arg" title="Permalink to this definition">¶</a></dt>
<dd><p>When <a class="reference internal" href="#cmdoption-lit-vg"><code class="xref std std-option docutils literal notranslate"><span class="pre">--vg</span></code></a> is used, specify an additional argument to pass to
<strong class="program">valgrind</strong> itself.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-vg-leak">
<code class="sig-name descname">--vg-leak</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-vg-leak" title="Permalink to this definition">¶</a></dt>
<dd><p>When <a class="reference internal" href="#cmdoption-lit-vg"><code class="xref std std-option docutils literal notranslate"><span class="pre">--vg</span></code></a> is used, enable memory leak checks.  When this option is
enabled, <strong class="program">lit</strong> will also automatically provide a “<code class="docutils literal notranslate"><span class="pre">vg_leak</span></code>”
feature that can be used to conditionally disable (or expect failure in)
certain tests.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-time-tests">
<code class="sig-name descname">--time-tests</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-time-tests" title="Permalink to this definition">¶</a></dt>
<dd><p>Track the wall time individual tests take to execute and includes the results
in the summary output.  This is useful for determining which tests in a test
suite take the most time to execute.  Note that this option is most useful
with <code class="docutils literal notranslate"><span class="pre">-j</span> <span class="pre">1</span></code>.</p>
</dd></dl>

</div>
<div class="section" id="selection-options">
<span id="id3"></span><h2>SELECTION OPTIONS<a class="headerlink" href="#selection-options" title="Permalink to this headline">¶</a></h2>
<dl class="std option">
<dt id="cmdoption-lit-max-tests">
<code class="sig-name descname">--max-tests</code><code class="sig-prename descclassname">=N</code><a class="headerlink" href="#cmdoption-lit-max-tests" title="Permalink to this definition">¶</a></dt>
<dd><p>Run at most <code class="docutils literal notranslate"><span class="pre">N</span></code> tests and then terminate.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-max-time">
<code class="sig-name descname">--max-time</code><code class="sig-prename descclassname">=N</code><a class="headerlink" href="#cmdoption-lit-max-time" title="Permalink to this definition">¶</a></dt>
<dd><p>Spend at most <code class="docutils literal notranslate"><span class="pre">N</span></code> seconds (approximately) running tests and then terminate.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-shuffle">
<code class="sig-name descname">--shuffle</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-shuffle" title="Permalink to this definition">¶</a></dt>
<dd><p>Run the tests in a random order.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-num-shards">
<code class="sig-name descname">--num-shards</code><code class="sig-prename descclassname">=M</code><a class="headerlink" href="#cmdoption-lit-num-shards" title="Permalink to this definition">¶</a></dt>
<dd><p>Divide the set of selected tests into <code class="docutils literal notranslate"><span class="pre">M</span></code> equal-sized subsets or
“shards”, and run only one of them.  Must be used with the
<code class="docutils literal notranslate"><span class="pre">--run-shard=N</span></code> option, which selects the shard to run. The environment
variable <code class="docutils literal notranslate"><span class="pre">LIT_NUM_SHARDS</span></code> can also be used in place of this
option. These two options provide a coarse mechanism for paritioning large
testsuites, for parallel execution on separate machines (say in a large
testing farm).</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-run-shard">
<code class="sig-name descname">--run-shard</code><code class="sig-prename descclassname">=N</code><a class="headerlink" href="#cmdoption-lit-run-shard" title="Permalink to this definition">¶</a></dt>
<dd><p>Select which shard to run, assuming the <code class="docutils literal notranslate"><span class="pre">--num-shards=M</span></code> option was
provided. The two options must be used together, and the value of <code class="docutils literal notranslate"><span class="pre">N</span></code>
must be in the range <code class="docutils literal notranslate"><span class="pre">1..M</span></code>. The environment variable
<code class="docutils literal notranslate"><span class="pre">LIT_RUN_SHARD</span></code> can also be used in place of this option.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-filter">
<code class="sig-name descname">--filter</code><code class="sig-prename descclassname">=REGEXP</code><a class="headerlink" href="#cmdoption-lit-filter" title="Permalink to this definition">¶</a></dt>
<dd><p>Run only those tests whose name matches the regular expression specified in
<code class="docutils literal notranslate"><span class="pre">REGEXP</span></code>. The environment variable <code class="docutils literal notranslate"><span class="pre">LIT_FILTER</span></code> can be also used in place
of this option, which is especially useful in environments where the call
to <code class="docutils literal notranslate"><span class="pre">lit</span></code> is issued indirectly.</p>
</dd></dl>

</div>
<div class="section" id="additional-options">
<h2>ADDITIONAL OPTIONS<a class="headerlink" href="#additional-options" title="Permalink to this headline">¶</a></h2>
<dl class="std option">
<dt id="cmdoption-lit-debug">
<code class="sig-name descname">--debug</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-debug" title="Permalink to this definition">¶</a></dt>
<dd><p>Run <strong class="program">lit</strong> in debug mode, for debugging configuration issues and
<strong class="program">lit</strong> itself.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-show-suites">
<code class="sig-name descname">--show-suites</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-show-suites" title="Permalink to this definition">¶</a></dt>
<dd><p>List the discovered test suites and exit.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-lit-show-tests">
<code class="sig-name descname">--show-tests</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lit-show-tests" title="Permalink to this definition">¶</a></dt>
<dd><p>List all of the discovered tests and exit.</p>
</dd></dl>

</div>
<div class="section" id="exit-status">
<h2>EXIT STATUS<a class="headerlink" href="#exit-status" title="Permalink to this headline">¶</a></h2>
<p><strong class="program">lit</strong> will exit with an exit code of 1 if there are any FAIL or XPASS
results.  Otherwise, it will exit with the status 0.  Other exit codes are used
for non-test related failures (for example a user error or an internal program
error).</p>
</div>
<div class="section" id="test-discovery">
<span id="id4"></span><h2>TEST DISCOVERY<a class="headerlink" href="#test-discovery" title="Permalink to this headline">¶</a></h2>
<p>The inputs passed to <strong class="program">lit</strong> can be either individual tests, or entire
directories or hierarchies of tests to run.  When <strong class="program">lit</strong> starts up, the
first thing it does is convert the inputs into a complete list of tests to run
as part of <em>test discovery</em>.</p>
<p>In the <strong class="program">lit</strong> model, every test must exist inside some <em>test suite</em>.
<strong class="program">lit</strong> resolves the inputs specified on the command line to test suites
by searching upwards from the input path until it finds a <code class="file docutils literal notranslate"><span class="pre">lit.cfg</span></code> or
<code class="file docutils literal notranslate"><span class="pre">lit.site.cfg</span></code> file.  These files serve as both a marker of test suites
and as configuration files which <strong class="program">lit</strong> loads in order to understand
how to find and run the tests inside the test suite.</p>
<p>Once <strong class="program">lit</strong> has mapped the inputs into test suites it traverses the
list of inputs adding tests for individual files and recursively searching for
tests in directories.</p>
<p>This behavior makes it easy to specify a subset of tests to run, while still
allowing the test suite configuration to control exactly how tests are
interpreted.  In addition, <strong class="program">lit</strong> always identifies tests by the test
suite they are in, and their relative path inside the test suite.  For
appropriately configured projects, this allows <strong class="program">lit</strong> to provide
convenient and flexible support for out-of-tree builds.</p>
</div>
<div class="section" id="test-status-results">
<span id="id5"></span><h2>TEST STATUS RESULTS<a class="headerlink" href="#test-status-results" title="Permalink to this headline">¶</a></h2>
<p>Each test ultimately produces one of the following six results:</p>
<p><strong>PASS</strong></p>
<blockquote>
<div><p>The test succeeded.</p>
</div></blockquote>
<p><strong>XFAIL</strong></p>
<blockquote>
<div><p>The test failed, but that is expected.  This is used for test formats which allow
specifying that a test does not currently work, but wish to leave it in the test
suite.</p>
</div></blockquote>
<p><strong>XPASS</strong></p>
<blockquote>
<div><p>The test succeeded, but it was expected to fail.  This is used for tests which
were specified as expected to fail, but are now succeeding (generally because
the feature they test was broken and has been fixed).</p>
</div></blockquote>
<p><strong>FAIL</strong></p>
<blockquote>
<div><p>The test failed.</p>
</div></blockquote>
<p><strong>UNRESOLVED</strong></p>
<blockquote>
<div><p>The test result could not be determined.  For example, this occurs when the test
could not be run, the test itself is invalid, or the test was interrupted.</p>
</div></blockquote>
<p><strong>UNSUPPORTED</strong></p>
<blockquote>
<div><p>The test is not supported in this environment.  This is used by test formats
which can report unsupported tests.</p>
</div></blockquote>
<p>Depending on the test format tests may produce additional information about
their status (generally only for failures).  See the <a class="reference internal" href="#output-options"><span class="std std-ref">OUTPUT OPTIONS</span></a>
section for more information.</p>
</div>
<div class="section" id="lit-infrastructure">
<span id="id6"></span><h2>LIT INFRASTRUCTURE<a class="headerlink" href="#lit-infrastructure" title="Permalink to this headline">¶</a></h2>
<p>This section describes the <strong class="program">lit</strong> testing architecture for users interested in
creating a new <strong class="program">lit</strong> testing implementation, or extending an existing one.</p>
<p><strong class="program">lit</strong> proper is primarily an infrastructure for discovering and running
arbitrary tests, and to expose a single convenient interface to these
tests. <strong class="program">lit</strong> itself doesn’t know how to run tests, rather this logic is
defined by <em>test suites</em>.</p>
<div class="section" id="test-suites">
<h3>TEST SUITES<a class="headerlink" href="#test-suites" title="Permalink to this headline">¶</a></h3>
<p>As described in <a class="reference internal" href="#test-discovery"><span class="std std-ref">TEST DISCOVERY</span></a>, tests are always located inside a <em>test
suite</em>.  Test suites serve to define the format of the tests they contain, the
logic for finding those tests, and any additional information to run the tests.</p>
<p><strong class="program">lit</strong> identifies test suites as directories containing <code class="docutils literal notranslate"><span class="pre">lit.cfg</span></code> or
<code class="docutils literal notranslate"><span class="pre">lit.site.cfg</span></code> files (see also <a class="reference internal" href="#cmdoption-lit-config-prefix"><code class="xref std std-option docutils literal notranslate"><span class="pre">--config-prefix</span></code></a>).  Test suites are
initially discovered by recursively searching up the directory hierarchy for
all the input files passed on the command line.  You can use
<a class="reference internal" href="#cmdoption-lit-show-suites"><code class="xref std std-option docutils literal notranslate"><span class="pre">--show-suites</span></code></a> to display the discovered test suites at startup.</p>
<p>Once a test suite is discovered, its config file is loaded.  Config files
themselves are Python modules which will be executed.  When the config file is
executed, two important global variables are predefined:</p>
<p><strong>lit_config</strong></p>
<blockquote>
<div><p>The global <strong>lit</strong> configuration object (a <em>LitConfig</em> instance), which defines
the builtin test formats, global configuration parameters, and other helper
routines for implementing test configurations.</p>
</div></blockquote>
<p><strong>config</strong></p>
<blockquote>
<div><p>This is the config object (a <em>TestingConfig</em> instance) for the test suite,
which the config file is expected to populate.  The following variables are also
available on the <em>config</em> object, some of which must be set by the config and
others are optional or predefined:</p>
<p><strong>name</strong> <em>[required]</em> The name of the test suite, for use in reports and
diagnostics.</p>
<p><strong>test_format</strong> <em>[required]</em> The test format object which will be used to
discover and run tests in the test suite.  Generally this will be a builtin test
format available from the <em>lit.formats</em> module.</p>
<p><strong>test_source_root</strong> The filesystem path to the test suite root.  For out-of-dir
builds this is the directory that will be scanned for tests.</p>
<p><strong>test_exec_root</strong> For out-of-dir builds, the path to the test suite root inside
the object directory.  This is where tests will be run and temporary output files
placed.</p>
<p><strong>environment</strong> A dictionary representing the environment to use when executing
tests in the suite.</p>
<p><strong>suffixes</strong> For <strong>lit</strong> test formats which scan directories for tests, this
variable is a list of suffixes to identify test files.  Used by: <em>ShTest</em>.</p>
<p><strong>substitutions</strong> For <strong>lit</strong> test formats which substitute variables into a test
script, the list of substitutions to perform.  Used by: <em>ShTest</em>.</p>
<p><strong>unsupported</strong> Mark an unsupported directory, all tests within it will be
reported as unsupported.  Used by: <em>ShTest</em>.</p>
<p><strong>parent</strong> The parent configuration, this is the config object for the directory
containing the test suite, or None.</p>
<p><strong>root</strong> The root configuration.  This is the top-most <strong class="program">lit</strong> configuration in
the project.</p>
<p><strong>pipefail</strong> Normally a test using a shell pipe fails if any of the commands
on the pipe fail. If this is not desired, setting this variable to false
makes the test fail only if the last command in the pipe fails.</p>
<p><strong>available_features</strong> A set of features that can be used in <cite>XFAIL</cite>,
<cite>REQUIRES</cite>, and <cite>UNSUPPORTED</cite> directives.</p>
</div></blockquote>
</div>
<div class="section" id="id7">
<h3>TEST DISCOVERY<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h3>
<p>Once test suites are located, <strong class="program">lit</strong> recursively traverses the source
directory (following <em>test_source_root</em>) looking for tests.  When <strong class="program">lit</strong>
enters a sub-directory, it first checks to see if a nested test suite is
defined in that directory.  If so, it loads that test suite recursively,
otherwise it instantiates a local test config for the directory (see
<a class="reference internal" href="#local-configuration-files"><span class="std std-ref">LOCAL CONFIGURATION FILES</span></a>).</p>
<p>Tests are identified by the test suite they are contained within, and the
relative path inside that suite.  Note that the relative path may not refer to
an actual file on disk; some test formats (such as <em>GoogleTest</em>) define
“virtual tests” which have a path that contains both the path to the actual
test file and a subpath to identify the virtual test.</p>
</div>
<div class="section" id="local-configuration-files">
<span id="id8"></span><h3>LOCAL CONFIGURATION FILES<a class="headerlink" href="#local-configuration-files" title="Permalink to this headline">¶</a></h3>
<p>When <strong class="program">lit</strong> loads a subdirectory in a test suite, it instantiates a
local test configuration by cloning the configuration for the parent directory
— the root of this configuration chain will always be a test suite.  Once the
test configuration is cloned <strong class="program">lit</strong> checks for a <em>lit.local.cfg</em> file
in the subdirectory.  If present, this file will be loaded and can be used to
specialize the configuration for each individual directory.  This facility can
be used to define subdirectories of optional tests, or to change other
configuration parameters — for example, to change the test format, or the
suffixes which identify test files.</p>
</div>
<div class="section" id="pre-defined-substitutions">
<h3>PRE-DEFINED SUBSTITUTIONS<a class="headerlink" href="#pre-defined-substitutions" title="Permalink to this headline">¶</a></h3>
<p><strong class="program">lit</strong> provides various patterns that can be used with the RUN command.
These are defined in TestRunner.py. The base set of substitutions are:</p>
<blockquote>
<div><table class="docutils align-default">
<colgroup>
<col style="width: 14%" />
<col style="width: 86%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Macro</p></th>
<th class="head"><p>Substitution</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>%s</p></td>
<td><p>source path (path to the file currently being run)</p></td>
</tr>
<tr class="row-odd"><td><p>%S</p></td>
<td><p>source dir (directory of the file currently being run)</p></td>
</tr>
<tr class="row-even"><td><p>%p</p></td>
<td><p>same as %S</p></td>
</tr>
<tr class="row-odd"><td><p>%{pathsep}</p></td>
<td><p>path separator</p></td>
</tr>
<tr class="row-even"><td><p>%t</p></td>
<td><p>temporary file name unique to the test</p></td>
</tr>
<tr class="row-odd"><td><p>%T</p></td>
<td><p>parent directory of %t (not unique, deprecated, do not use)</p></td>
</tr>
<tr class="row-even"><td><p>%%</p></td>
<td><p>%</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p>Other substitutions are provided that are variations on this base set and
further substitution patterns can be defined by each test module. See the
modules <a class="reference internal" href="#local-configuration-files"><span class="std std-ref">LOCAL CONFIGURATION FILES</span></a>.</p>
<p>More detailed information on substitutions can be found in the
<a class="reference internal" href="../TestingGuide.html"><span class="doc">LLVM Testing Infrastructure Guide</span></a>.</p>
</div>
<div class="section" id="test-run-output-format">
<h3>TEST RUN OUTPUT FORMAT<a class="headerlink" href="#test-run-output-format" title="Permalink to this headline">¶</a></h3>
<p>The <strong class="program">lit</strong> output for a test run conforms to the following schema, in
both short and verbose modes (although in short mode no PASS lines will be
shown).  This schema has been chosen to be relatively easy to reliably parse by
a machine (for example in buildbot log scraping), and for other tools to
generate.</p>
<p>Each test result is expected to appear on a line that matches:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&lt;result code&gt;: &lt;test name&gt; (&lt;progress info&gt;)
</pre></div>
</div>
<p>where <code class="docutils literal notranslate"><span class="pre">&lt;result-code&gt;</span></code> is a standard test result such as PASS, FAIL, XFAIL,
XPASS, UNRESOLVED, or UNSUPPORTED.  The performance result codes of IMPROVED and
REGRESSED are also allowed.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">&lt;test</span> <span class="pre">name&gt;</span></code> field can consist of an arbitrary string containing no
newline.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">&lt;progress</span> <span class="pre">info&gt;</span></code> field can be used to report progress information such
as (1/300) or can be empty, but even when empty the parentheses are required.</p>
<p>Each test result may include additional (multiline) log information in the
following format:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&lt;log delineator&gt; TEST &#39;(&lt;test name&gt;)&#39; &lt;trailing delineator&gt;
... log message ...
&lt;log delineator&gt;
</pre></div>
</div>
<p>where <code class="docutils literal notranslate"><span class="pre">&lt;test</span> <span class="pre">name&gt;</span></code> should be the name of a preceding reported test, <code class="docutils literal notranslate"><span class="pre">&lt;log</span>
<span class="pre">delineator&gt;</span></code> is a string of “*” characters <em>at least</em> four characters long
(the recommended length is 20), and <code class="docutils literal notranslate"><span class="pre">&lt;trailing</span> <span class="pre">delineator&gt;</span></code> is an arbitrary
(unparsed) string.</p>
<p>The following is an example of a test run output which consists of four tests A,
B, C, and D, and a log message for the failing test C:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>PASS: A (1 of 4)
PASS: B (2 of 4)
FAIL: C (3 of 4)
******************** TEST &#39;C&#39; FAILED ********************
Test &#39;C&#39; failed as a result of exit code 1.
********************
PASS: D (4 of 4)
</pre></div>
</div>
</div>
<div class="section" id="lit-example-tests">
<h3>LIT EXAMPLE TESTS<a class="headerlink" href="#lit-example-tests" title="Permalink to this headline">¶</a></h3>
<p>The <strong class="program">lit</strong> distribution contains several example implementations of
test suites in the <em>ExampleTests</em> directory.</p>
</div>
</div>
<div class="section" id="see-also">
<h2>SEE ALSO<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2>
<p>valgrind(1)</p>
</div>
</div>


            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="llvm-build.html" title="llvm-build - LLVM Project Build Utility"
             >next</a> |</li>
        <li class="right" >
          <a href="tblgen.html" title="tblgen - Target Description To C++ Code Generator"
             >previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="index.html" >LLVM Command Guide</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">lit - LLVM Integrated Tester</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2003-2020, LLVM Project.
      Last updated on 2020-09-20.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
    </div>
  </body>
</html>